<html>
	<head>
		<title>Sonna: Post test</title>
		<script src="https://159.213.137.77/facebook/fxb_api/utils/utils.js" type="text/javascript"></script>
		<script src="https://159.213.137.77/facebook/fxb_api/request.js" type="text/javascript"></script>
		<script src="https://159.213.137.77/facebook/fxb_api/fXb_all.js" type="text/javascript"></script>
		
		
		<script type="text/javascript">
			function postMessage(){
				if(!_fb_user.isLogged()){
					alert('Please login first');
					return;
				}
				
				var elem_text = document.getElementById('post');
				var text = escape(elem_text.value);
				postProfileMessage(text, tempSuccess, tempFailure);
				savePost(_fb_user.getUserId(), text);
			}
			
			function checkKey(event, name){
				if (event.keyCode == 13)
					document.getElementById(name + '_btn').click();
			}
			
			function tempSuccess(result){
				log('Post ID: ' + result.id);	
			}
			
			function tempFailure(result){
				log('c\' stato qualche problema!');	
			}	
			
			function saveUserId(resp){
				var req = new Request();
				req.setOnSuccess(tempSuccess);
				req.setOnFailure(tempFailure);
				req.asyncPutRequest('../services/service.php/' + resp.userID);
			}
			
			function savePost(userId, post){
				var req = new Request();
				req.setOnSuccess(tempSuccess);
				req.setOnFailure(tempFailure);
				req.asyncPutRequest('../services/service.php/' + userId + '/' + post);
			}
		</script>
	</head>
	<body>
		<h3>Test salvataggio dati Post</h3>
		<div style="display: block">
			<div style="display: block">
				<span>Post a new message: </span>
				<input type="text" name="post" id="post" onkeydown="checkKey(event, this.id);"/>
				<input type="button" name="post_btn" id="post_btn" value="Post" onclick="postMessage();"/>
			</div>
		</div>
		
		
		<div id="fb-root">
			
		</div>
		<!--input type="button" name="createXVRObj" value="createXVRObj" id="createXVRObj" onclick="createXVRObj();" /-->
		<!--input type="button" name="login" value="login" id="login" onclick="login(saveUserId);" />
		<input type="button" name="logout" value="logout" id="logout" onclick="logout();" /-->
		
		<div class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1"></div>
		
		<div style="display: block">
			<div class="fb-activity" data-site="159.213.137.77" data-width="300" data-height="300" data-header="true" data-recommendations="true"></div>
			<div class="fb-comments" data-href="https://159.213.137.77/facebook/test3/post.html" data-num-posts="2" data-width="470"></div>
			<div class="fb-like" data-send="true" data-width="450" data-show-faces="true"></div>
		</div>
		

	</body>
</html>